
classDiagram
    %% ---------------------
    %% 函数处理
    %% ---------------------
    class Metadata
    class Function
    class Callback
    class Queue
    class Thread

    %% 定义类型
    class NodeTypeEnum{
        <<enumeration>>
        METHONDTYPE
        CLASSTYPE
        FUNCTIONTYPE
    }

    %% NodeTypeEnum 类型
    %% name 节点名
    %% lineno 行号
    %% module 模块名
    %% filename 文件名
    %% metadata 元数据信息
    Metadata <-- BaseNode
    class BaseNode{
        +String NodeTypeEnum
        +String name
        +String lineno
        +String module
        +String filename
        +Metadata metadata
        %% 帧的实参的信息
        #Tuple argvalues
    }

    BaseNode: +get_type() String
    BaseNode: +get_name() String
    BaseNode: +get_lineno() String
    BaseNode: +get_module() String
    BaseNode: +get_filename() String
    BaseNode: +get_metadata() Metadata
    BaseNode: +is_builtins() Boolean
    BaseNode: -__eq__() Boolean

    %% 函数类型
    BaseNode <|-- FunctionNode
    class FunctionNode~BaseNode~{
        
    }

    %% 类类型
    BaseNode <|-- ClassNode
    class ClassNode~BaseNode~{
        
    }

    %% 方法类型
    BaseNode <|-- MethodNode
    class MethodNode~BaseNode~{
        
    }

    BaseNode -- NodeFactory
    class NodeFactory
    NodeFactory : Metadata data
    NodeFactory : +create() BaseNode


    class Implementor
    <<interface>> Implementor
    %% 获取类型
    Implementor: +get_type() String
    %% 获取模块名
    Implementor: +get_name() String
    %% 获取模块代码行
    Implementor: +get_lineno() String
    %% 获取模块
    Implementor: +get_module() String
    %% 获取模块文件名
    Implementor: +get_filename() String
    %% 获取模块元数据
    Implementor: +get_metadata() Metadata

    BaseNode <.. NodeFrame
    NodeFrame ..|> Implementor
    class NodeFrame~Implementor~
    NodeFrame : +BaseNode node
    NodeFrame : +Callback func
    NodeFrame : get_type() String
    NodeFrame : get_name() String
    NodeFrame : get_lineno() String
    NodeFrame : get_module() String
    NodeFrame : get_filename() String
    NodeFrame : get_metadata() Metadata
    NodeFrame : get_fullargspec() Tuple
    %% 获取传入特定的帧的实参的信息
    NodeFrame : get_argvalues() Tuple


    NodeRelation o-- NodeFrame
    class NodeRelation
    NodeRelation : +List[NodeFrame] nodes
    NodeRelation : +Float cost
    NodeRelation : +NodeFrame prev
    NodeRelation : +NodeFrame next
    NodeRelation : -__iter__() Iterator
    NodeRelation : -__add__(NodeFrame)
    NodeRelation : -__iadd__(NodeFrame)
    NodeRelation : -__eq__() Boolean

    %% 解析适配器
    class AdapterImplementor
    <<interface>> AdapterImplementor
    %% 解析代码
    AdapterImplementor : +parser(Tuple) BaseNode
    %% BaseNode --->转换对应的node[NodeFrame]
    AdapterImplementor : +convert(BaseNode) NodeFrame
    %% 拼接节点
    AdapterImplementor : +concat(NodeFrame) NodeRelation
    %% 获取自 Python 函数或方法 func 引用的外部名字到它们的值的映射
    AdapterImplementor : +get_closurevars(Function) Tuple

    DefaultAdapter ..|> AdapterImplementor
    class DefaultAdapter~AdapterImplementor~

    class DefaultCallback
    %% 静态方法 : 鼠标 略过节点
    DefaultCallback : ~hover(*args, **kw)
    DefaultCallback : ~click(*args, **kw)
    DefaultCallback : ~double_click(*args, **kw)

    %% 默认的事件驱动
    DefaultCallback -- CallbackFactory
    class CallbackFactory
    CallbackFactory : +Config config
    CallbackFactory : +create() DefaultCallback

    %% 绘制，属于事件驱动触发的
    class DrawingImplementor
    <<interface>> DrawingImplementor
    DrawingImplementor : BaseNode
    %% 事件名
    DrawingImplementor : +String name
    DrawingImplementor : +DefaultCallback func

    %% 绘制节点
    DrawingImplementor <|.. NodeDrawing
    class NodeDrawing~DrawingImplementor~

    %% 绘制选择节点后的表格信息
    DrawingImplementor <|.. NodeTableDrawing
    class NodeTableDrawing~DrawingImplementor~

    %% 绘制节点所对应的文件
    DrawingImplementor <|.. NodeFileDrawing
    class NodeFileDrawing~DrawingImplementor~

    %% 绘制节点的元数据
    DrawingImplementor <|.. NodeMetaDrawing
    class NodeMetaDrawing~DrawingImplementor~

    %% 事件监听
    NodeMetaDrawing <-- EventListener
    NodeFileDrawing <-- EventListener
    NodeTableDrawing <-- EventListener
    NodeDrawing <-- EventListener
    class EventListener
    EventListener : +List event_listeners
    %% 装饰器
    EventListener : +on_listen(DrawingImplementor)
    
    %% 定义事件
    class NodeEvent
    %% 事件名
    NodeEvent : String name
    NodeEvent : BaseNode node
    
    %% 定义事件驱动节点管理器
    EventListener <-- EventEngine
    NodeEvent <.. EventEngine
    Queue <.. EventEngine
    Thread <|-- EventEngine
    class EventEngine~Thread~
    EventEngine : +Mapping[String, DrawingImplementor]
    EventEngine : +attach(DrawingImplementor)
    EventEngine : +detach(String)
    EventEngine : +on_event(NodeEvent)
    EventEngine : +recv(NodeEvent)
    EventEngine : +send(NodeEvent)
    EventEngine : +start(NodeEvent)
    EventEngine : +stop(NodeEvent)
    EventEngine : +binding(CallbackFactory)
    EventEngine : +get_handlers() Mapping[String, DrawingImplementor]

    ProccessParser ..> DefaultAdapter
    Function <.. ProccessParser
    NodeFactory <.. ProccessParser
    %% 递归解析器
    class ProccessParser
    %% 装饰的函数
    ProccessParser : -Function func
    %% 解析适配
    ProccessParser : +DefaultAdapter proccess_adapter
    %% 装饰器
    ProccessParser : -__call__(Function) None
    ProccessParser : +parser(Tuple) BaseNode
    ProccessParser : +convert(BaseNode) NodeFrame
    ProccessParser : +concat(NodeFrame) NodeRelation
    ProccessParser : +get_closurevars(Function) Tuple
    %% 扫模块
    ProccessParser : +scan(Function) Tuple

    %% ---------------------
    %% 组合业务逻辑
    %% ---------------------
    ProccessParser <-- PanelFacade
    EventEngine <-- PanelFacade
    class PanelFacade
    PanelFacade : +ProccessParser proccess_parser
    PanelFacade : +EventEngine event_engine
    PanelFacade : +start()
    PanelFacade : +get_nodes() nodes
    PanelFacade : +get_handlers() Any
    PanelFacade : +stop()
    %% 动态更新
    PanelFacade : +set_callback(CallbackFactory)
    PanelFacade : +set_adapter(DefaultAdapter)
    PanelFacade : +send(NodeEvent)
    PanelFacade : +is_alive() Boolean

    %% ---------------------
    %% 框架
    %% ---------------------
    namespace server

        class ServerConfig
        class FastAPI
        FastAPI : +run()

        PanelFacade <-- BaseServer
        ServerConfig <-- BaseServer
        FastAPI <-- BaseServer
        class BaseServer
        BaseServer : +PanelFacade panel_facade
        BaseServer : +ServerConfig server_config
        BaseServer : +FastAPI api
        %% 内置服务
        BaseServer <|-- Server
        class Server~BaseServer~
        %% C/S
        BaseServer <|-- ConsoleServer
        class ConsoleServer~BaseServer~
        %% B/S
        BaseServer <|-- WebServer
        class WebServer~BaseServer~

        Server <-- Selector
        ConsoleServer <-- Selector
        WebServer <-- Selector
        class Selector

        Selector <-- ServerContainer
        class ServerContainer
        %% Selector --> Union[Server, ConsoleServer, WebServer]
        ServerContainer : +Selector selector

    namespace root

        %% 配置文件加载
        class FileHandler
        FileHandler : +read() String
        FileHandler : -read_ini() String
        FileHandler : -read_json() String
        FileHandler : -read_yaml() String

        %% 配置文件
        class Config

        %% 日志模块
        Config <-- Logger
        class Logger
        Logger : +Config config
        Logger : set_level(*args, **kw)

        %% 容器模块
        ServerContainer <-- Container
        Logger <-- Container
        Config <-- Container
        class Container
        Container : +ServerContainer server_container
        Container : +Config config
        Container : +Logger logger

        %% 主程序
        Container <-- Proccess
        FileHandler <-- Proccess
        class Proccess
        Proccess : +Container container
        Proccess : +FileHandler file_handler
        Proccess : -run()
        Proccess : +start()
        Proccess : +stop()
        Proccess : -init_config()
        
        Proccess -- main
        class main
 




